package com.itheima_04;

import java.lang.reflect.Array;

/*
    数组最大值：设计一个方法用于获取数组中元素的最大值
 */
public class getArrayMax {
    public static void main(String[] args) {
        int[] arr = {1, 3, 5, 7, 9, 0, 2, 4, 6, 8};
        System.out.println("已知数组如下：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + "\t");
        }
        System.out.println("\r\n");
        System.out.println("max:" + getArrMax(arr));
    }

    private static int getArrMax(int[] arr) {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i]) {
                max = arr[i];
            }
        }
        return max;
    }
}
